<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body,
      ul {
        margin: 0;
        padding: 0;
      }
      body {
        width: 100%;
        height: 100%;
        background-image: url(../../images/grid.png);
      }
      svg {
        background-color: rgba(255, 0, 0, 0.1);
      }
    </style>
  </head>
  <body>
    <svg width="300" height="300">
      <rect
        id="rectangle"
        x="100"
        y="100"
        width="100"
        height="100"
        fill="red"
        onclick="scaleRectangle()"
      ></rect>
    </svg>

    <script src="./libs/gsap.min.js"></script>
    <script>
      function scaleRectangle() {
        // 补间动画(参数已支持数组)
        /* gsap.to(['#rectangle'], {
          scale: 0.5,     // 1 - 0.5
          duration: 1,
        }) */

        /* gsap.from('#rectangle', {
          scale: 0.3, // 0.3 - 1
          duration: 1,
        }) */

        /* gsap.fromTo(
          ['#rectangle'],
          {
            // 0%
            scale: 0,
          },
          {
            // 100%
            scale: 1,
            duration: 1,
            repeat: 1,
          }
        ) */

        /* gsap.to(['#rectangle'], {
          scale: 0.5,
          duration: 1,
          transformOrigin: 'center',
        }) */

        gsap.to(['#rectangle'], {
          scale: 0.5,
          duration: 1,
          transformOrigin: 'center',
          ease: 'bounce.out',
        })
      }
    </script>
  </body>
</html>
